package databases

import (
	"Godzilla/common/ini"
	"log"
)

var redisMap = make(map[string]string)

func GetRedisConfig(str string) string {

	return redisMap[str]
}

func SetRedisConfig(key string, value string) bool {
	redisMap[key] = value
	if _, err :=redisMap[key]; err == false {
		return false
	}
	return true
}

func RedisSetConfig() bool {
	var (
		Host 	string
		Port	string
		Num		string
	)

	driver := "redis"

	cfg, err := ini.NewIni()
	if err != nil {
		log.Println(err)
		return false
	}

	Host = cfg.Section(driver).Key("Host").String()
	Port = cfg.Section(driver).Key("Port").String()
	Num  = cfg.Section(driver).Key("Num").String()

	SetRedisConfig("Host",Host)
	SetRedisConfig("Port", Port)
	SetRedisConfig("Num", Num)

	return true

}